<template>
  <div class="wrap">
    <div class="order">最近浏览</div>

    <div class="content">
      <div class="product" v-for="(item,index) in recently">
        <img class="del" @click="cancel(index)" src="@/assets/mine/del.png" alt="">
        <img :src="item.product_img" alt="">
        <p class="name">{{item.product_name}}</p>
        <span class="intro">{{item.product_intro}}</span>
        <div class="price">
          <span class="xian">￥{{item.product_price}}</span>
          <span class="yuan">￥{{item.product_oriprice}}</span>
          <img class="cart" src="@/assets/mine/cart.png" alt="">
        </div>
      </div>
      <div style="clear: both"></div>
    </div>
  </div>
</template>

<script>
  import Axios from 'axios'
  export default {
    name: "Recently",
    data() {
      return {
        recently: []
      }
    },
    methods: {
      cancel(ind) {
        var id = this.recently[ind].recently_id;
        console.log(id);
        var con = confirm('确定要删除吗？');
        if (con == true) {
          var params = new URLSearchParams();
          params.append('recently_id', id);
          Axios.post('/api/recently/del', params).then(res => {

          });
          location.reload();
        } else {
          return
        }
      }
    },
    mounted() {
      var params = new URLSearchParams();
      params.append('user_id', 1);
      Axios.post('/api/recently/get', params).then(res => {
        this.recently = res.data;
      });
    }
  }
</script>

<style scoped>
  .wrap {
    box-sizing: border-box;
    width: 100%;
    min-height: 626px;
    border: 1px solid #e9e9e9;
  }
  .order {
    box-sizing: border-box;
    width: 100%;
    height: 58px;
    padding-left: 20px;
    font-size: 18px;
    line-height: 58px;
    border-bottom: 1px solid #e9e9e9;
  }
  .content {
    padding: 40px;
    padding-bottom: 0;
  }

  .product {
    position: relative;
    box-sizing: border-box;
    float: left;
    width: 300px;
    height: 430px;
    padding: 20px;
    margin-bottom: 40px;
    border: 1px solid #e9e9e9;
  }
  .content .product:nth-of-type(3n+2) {
    margin: 0 50px;
  }
  .product>img {
    width: 100%;
  }
  .product>img.del {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
  }
  .name {
    font-size: 18px;
    margin-bottom: 16px;
  }
  .intro {
    font-size: 14px;
    color: #a3a3a3;
  }
  .price {
    margin: 16px 0;
  }
  .xian {
    font-size: 24px;
    color:#ff5757;
  }
  .yuan {
    font-size: 18px;
    color: #a3a3a3;
    text-decoration: line-through;
  }
  .cart {
    float: right;
  }

</style>
